const {
  Controller,
} = require('uni-cloud-router')

const ResponseUtil = require('../utils/Response.js')

module.exports = class PointsController extends Controller {
  async list() {
    const {
      ctx,
      service,
    } = this
    const {
      openId,
    } = ctx

    return service.points.list({ openId })
  }

  add() {
    const {
      ctx,
      service,
    } = this
    const {
      openId,
    } = ctx

    return service.points.add({ openId, ...ctx.event })
  }

  remove() {
    const {
      ctx,
      service,
    } = this
    const {
      openId,
    } = ctx

    return service.points.remove({ openId, ...ctx.event })
  }

  transaction() {
    const {
      ctx,
      service,
    } = this

    return service.points.transaction({ ...ctx.event })
  }
}
